<!--
 * @Author: your name
 * @Date: 2021-12-03 14:05:07
 * @LastEditTime: 2021-12-03 16:48:14
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vite-ts-adminc:\Users\16860\Desktop\index.html
-->
<!doctype html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>Elk-End</title>
    <style>
         .kuang{
              width: 100%;
              height: 100vh;
              background: #f6f5f0;
              box-shadow: .2rem .2rem .4rem #eae9e6,
		      -.2rem -.2rem .4rem #fff;
              display: flex;
              flex-direction: column;
              justify-content: center;
              align-items: center;
         }
         .kuang>div{
              margin-top: 10rem;
         }
         .send{
              width: 90%;
              height: 6rem;
              background: #f6f5f0;
              box-shadow: .2rem .2rem .4rem #eae9e6,
		      -.2rem -.2rem .4rem #fff;
              line-height: 6rem;
              border-radius: 5rem;
              font-size: 2.3rem;
              text-align: center;
              color: #5a5749;
         }
         .send:active{
              background: #d9f7e7;
         }
         .text{
            font-size: 3rem;
              text-align: center;
              color: #5a5749; 
         }
    </style>
</head>

<body>
    <div class="kuang">
         <div class="bgs">
                 <img src="http://120.76.142.67/Elk-Admin/assets/logologin.0bccd262.svg" alt="">
         </div> 
         <div class="text">
             欢迎扫码登录Elk-Admin
         </div>
         <div class="send" id="send">授权登录</div>
    </div>

    
    <script>
        var send = document.getElementById("send");
        let status = false;
        if (window.WebSocket) {
            document.querySelector(".send").onclick = function (e) {
                var ws = new WebSocket('ws://120.76.142.67:9652');
                ws.onopen = function (e) {
                    if(status) return;
                    status=true
                    let obj = {
                        name: 'keys',
                        value: '1637748857949'
                    }
                    ws.send(JSON.stringify(obj));
                    send.innerText='登录成功,欢迎使用！';
                    Object.assign(send.style ?? {},{
                         background:'#12ca65',
                         color:'#d9f7e7'
                    })
                   
                }

                ws.onmessage = function (e) {


                }

                ws.onclose = function (e) {
                    console.log("服务器关闭");
                }

                ws.onerror = function () {
                    console.log("连接出错");
                }
            }

        }
    </script>
</body>

</html>